package stub;

import java.io.File;
import java.net.URL;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.jdom.input.SAXBuilder;
import org.oos.services.util.URLUtils;
import org.w3c.dom.Document;

public class URLUtilsStub extends URLUtils
{
	public String testFile;
	
	public URLUtilsStub(String testFile) {
		super();
		this.testFile = testFile;
	}

	public Document retrieve(URL url) throws Exception
	{
		try
		{
			DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			File doc = new File(testFile);
			return docBuilder.parse(doc);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
	public Document retrieveWSSE(URL url, String email, String authToken)
	{
		try
		{
			DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			File doc = new File(testFile);
			return docBuilder.parse(doc);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
	public org.jdom.Document retrieveJDomWSSE(URL url, String email, String authToken) throws Exception
	{
		SAXBuilder parser = new SAXBuilder();
		return parser.build(new File(testFile));
	}

}
